<%--
  Created by IntelliJ IDEA.
  User: cyrus
  Date: 2021/04/10
  Time: 15:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<html>
<head>
    <title>修改</title>
    <%@include file="../../include/include.jsp" %>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <input type="hidden" id="resourceId" name="resourceId"
                   class="layui-input" value="${entity.resourceId}">
            <div class="layui-form-item">
                <label for="resourceName" class="layui-form-label">
                    <span class="x-red">*</span>资源名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="resourceName" name="resourceName" required="" autocomplete="off"
                           class="layui-input" value="${entity.resourceName}">
                </div>
            </div>


            <div class="layui-form-item">
                <label for="resourceCode" class="layui-form-label">
                    <span class="x-red">*</span>资源码</label>
                <div class="layui-input-inline">
                    <input type="text" id="resourceCode" name="resourceCode" required="" lay-verify="resourceCode"
                           autocomplete="off" class="layui-input" value="${entity.resourceCode}"></div>
            </div>

            <div class="layui-form-item">
                <label for="perm" class="layui-form-label">
                    <span class="x-red">*</span>权限
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="perm" name="perm" required="" autocomplete="off"
                           class="layui-input" value="${entity.perm}">
                </div>
            </div>


            <div class="layui-form-item">
                <label for="type" class="layui-form-label">
                    <span class="x-red">*</span>种类
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="type" name="type" required="" autocomplete="off"
                           class="layui-input" value="${entity.type}">
                </div>
            </div>


            <div class="layui-form-item">
                <label for="parentId" class="layui-form-label">
                    <span class="x-red">*</span>父节点
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="parentId" name="parentId" required="" autocomplete="off"
                           class="layui-input" value="${entity.parentId}">
                </div>
            </div>


            <div class="layui-form-item">
                <label for="url" class="layui-form-label">
                    <span class="x-red">*</span>url地址
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="url" name="url" required="" autocomplete="off"
                           class="layui-input" value="${entity.url}">
                </div>
            </div>


            <div class="layui-form-item">
                <label for="icon" class="layui-form-label">
                    <span class="x-red">*</span>图标
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="icon" name="icon" required="" autocomplete="off"
                           class="layui-input" value="${entity.icon}">
                </div>
            </div>


            <div class="layui-form-item">
                <label for="sort" class="layui-form-label">
                    <span class="x-red">*</span>排序
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="sort" name="sort" required="" autocomplete="off"
                           class="layui-input" value="${entity.sort}">
                </div>
            </div>


            <div class="layui-form-item">
                <label for="status" class="layui-form-label">
                    <span class="x-red">*</span>状态
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="status" id="status" required="" autocomplete="off"
                           class="layui-input" value="${entity.status}">
                </div>
            </div>


            <div class="layui-form-item">
                <label for="createdBy" class="layui-form-label">
                    <span class="x-red">*</span>创建人
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="createdBy" name="createdBy" required="" autocomplete="off"
                           class="layui-input" value="${entity.createdBy}">
                </div>
            </div>

            <div class="layui-form-item">
                <button class="layui-btn" lay-filter="add" lay-submit="">修改</button>
            </div>
        </form>
    </div>
</div>
<script>

    layui.use(['form', 'layer', 'jquery', 'laydate'], function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#birthday',
            trigger: "click",
            done(value, date, endDate) {
                $("#birthday").val(value);
            }
        });


        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //自定义验证规则
        form.verify({

        });

        //监听提交
        form.on('submit(add)',
            function (data) {
                console.log(data.field);
                //发异步，把数据提交给php

                $.ajax({
                    type: "POST",
                    url: "${ctx}/resource/edit",
                    data: data.field,
                    // data: JSON.stringify(data.field),
                    // // 设置请求头为json格式
                    // contentType: "application/json;charset=utf-8",

                    success(res) {
                        console.log(res)
                        if (res.success) {
                            layer.alert("增加成功", {
                                    icon: 6
                                },
                                function () {
                                    //关闭当前frame
                                    xadmin.close();

                                    // 可以对父窗口进行刷新
                                    xadmin.father_reload();
                                });
                        } else {
                            layer.alert(res.msg)
                        }

                    }
                });
                return false;
            });

    });</script>
<script>var _hmt = _hmt || [];
(function () {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>
</html>
